package com.nanhua.test1.service.impl;

import com.nanhua.test1.mapper.UserMapper;
import com.nanhua.test1.pojo.User;
import com.nanhua.test1.service.UserService;
import com.nanhua.test1.util.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public void register(String username, String password) {
        userMapper.register(username,password);
    }

    @Override
    public User findByName(String username) {
        return userMapper.findUserByName(username);
    }

    @Override
    public void updateAvatar(String avatarUrl) {
        Map<String,Object> map = ThreadLocalUtil.get();
        Integer id = (Integer) map.get("id");
    }

    @Override
    public void updatePwd(String rePwd) {
        Map<String,Object> map = ThreadLocalUtil.get();
        Integer id = (Integer) map.get("id");
    userMapper.updatePwd(rePwd,id);
    }

    @Override
    public User findById(Integer id) {
        return userMapper.findUserById(id);
    }

}

